<script>
  import config from './config'
  import { getToken } from '@/utils/auth'
  import Vue from "vue";

  export default {
    onLaunch: function() {
      this.initApp()
	  this.getSystemInfo()
    },
    methods: {
      // 初始化应用
      initApp() {
        // 初始化应用配置
        this.initConfig()
        // 检查用户登录状态
        //#ifdef H5
        this.checkLogin()
        //#endif
      },
	  //   初始化获取系统信息
	  getSystemInfo(){
		uni.getSystemInfo({
		    success: function(e) {
		      // #ifndef MP
		      Vue.prototype.StatusBar = e.statusBarHeight;
		      if (e.platform == 'android') {
		        Vue.prototype.CustomBar = e.statusBarHeight + 50;
		      } else {
		        Vue.prototype.CustomBar = e.statusBarHeight + 45;
		      };
		      // #endif
		      // #ifdef MP-WEIXIN
		      Vue.prototype.StatusBar = e.statusBarHeight;
		      let custom = wx.getMenuButtonBoundingClientRect();
		      Vue.prototype.Custom = custom;
		      Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
		      // #endif
		      // #ifdef MP-ALIPAY
		      Vue.prototype.StatusBar = e.statusBarHeight;
		      Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
		      // #endif
		    }
		  })
	  },
      initConfig() {
        this.globalData.config = config
      },
      checkLogin() {
        if (!getToken()) {
          this.$tab.reLaunch('/pages/login')
        }
      }
    },
  }
</script>

<style>
@import "@/static/font/iconfont.css";
@import '@/static/scss/index.scss'; /* 你的项目css */

</style>

